package ioc17;

import java.beans.PropertyEditorSupport;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateEditorSurport extends PropertyEditorSupport {
    @Override
    public void setAsText(String text) throws IllegalArgumentException {
        try {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = simpleDateFormat.parse(text);
        setValue(parse);
        } catch (Exception e) {
            e.printStackTrace();
            throw  new IllegalArgumentException("日期格式异常");
        }

    }
}
